<template>
    <div class="facilitator_param">
        <div class="content">
        <viewTitle :title="'账户详情'" :border="true"> </viewTitle>
        <div class="param_h">
            <div class="param_block flex felxR">
                <div class="param_block_title">
                    <span v-if="type > 0">*</span>服务商入账账户:
                </div>
                <div class="param_block_input">
                    <div v-if="type === 0"> {{detail.facilitator_bank_code}} </div>
                    <div v-else>
                        <el-input type="text" clearable placeholder="服务商入账账户"  v-model="detail.facilitator_bank_code"></el-input>
                    </div>
                </div>
            </div>
            <div class="param_block  flex felxR">
                <div class="param_block_title">
                    <span v-if="type > 0">*</span>服务商入账户名:
                </div>
                <div class="param_block_input">
                    <div v-if="type === 0"> {{detail.facilitator_account_name}} </div>
                    <div v-else>
                        <el-input type="text" clearable placeholder="服务商入账户名"  v-model="detail.facilitator_account_name"></el-input>
                    </div>
                </div>
            </div>
            <div class="param_block  flex felxR">
                <div class="param_block_title">
                    <span v-if="type > 0">*</span>服务商入账开户行:
                </div>
                <div class="param_block_input">
                    <div v-if="type === 0"> {{detail.facilitator_bank_name}} </div>
                    <div v-else>
                        <el-input type="text" clearable placeholder="服务商入账开户行"  v-model="detail.facilitator_bank_name"></el-input>
                    </div>
                </div>
            </div>
            <div class="param_block  flex felxR">
                <div class="param_block_title">
                    <span v-if="type > 0">*</span>代付商户编号:
                </div>
                <div class="param_block_input">
                    <div v-if="type === 0"> {{detail.facilitator_pay_code}} </div>
                    <div v-else>
                        <el-input type="text" clearable placeholder="代付商户编号"  v-model="detail.facilitator_pay_code"></el-input>
                    </div>
                </div>
            </div>
            <!-- 要占全宽部分start-->
            <div class="param_block_long  flex felxR">
                <div class="param_block_title">
                    <span v-if="type > 0">*</span>代付商户签名密钥:
                </div>
                <div class="param_block_input">
                    <div v-if="type === 0"> {{detail.facilitator_sign_key}} </div>
                    <div v-else>
                        <el-input type="text" clearable placeholder=" 代付商户签名密钥"  v-model="detail.facilitator_sign_key"></el-input>
                    </div>
                </div>
            </div>
            <div class="param_block_long  flex felxR">
                <div class="param_block_title">
                    <span v-if="type > 0">*</span>代付商户SM2公钥:
                </div>
                <div class="param_block_input">
                    <div v-if="type === 0"> {{detail.facilitator_sm2_pub}} </div>
                    <div v-else>
                        <el-input type="text" clearable placeholder=" 代付商户SM2公钥"  v-model="detail.facilitator_sm2_pub"></el-input>
                    </div>
                </div>
            </div>
            <div class="param_block_long  flex felxR">
                <div class="param_block_title">
                    <span v-if="type > 0">*</span>代付商户SM2私钥:
                </div>
                <div class="param_block_input">
                    <div v-if="type === 0"> {{detail.facilitator_sm2_key}} </div>
                    <div v-else>
                        <el-input type="text" clearable placeholder="代付商户SM2私钥"  v-model="detail.facilitator_sm2_key"></el-input>
                    </div>
                </div>
            </div>
            <!-- 要占全宽部分end-->
            <div class="param_block  flex felxR">
                <div class="param_block_title">
                    <span v-if="type > 0">*</span>银企直联用户名 :
                </div>
                <div class="param_block_input">
                    <div v-if="type === 0"> {{detail.bank_and_enterprise_name}} </div>
                    <div v-else>
                        <el-input type="text" clearable placeholder="银企直联用户名"  v-model="detail.bank_and_enterprise_name"></el-input>
                    </div>
                </div>
            </div>
            <div class="param_block  flex felxR">
                <div class="param_block_title">
                    <span v-if="type > 0">*</span>银企直联密码 :
                </div>
                <div class="param_block_input">
                    <div v-if="type === 0"> {{detail.bank_and_enterprise_password}} </div>
                    <div v-else>
                        <el-input type="text" clearable placeholder="银企直联密码"  v-model="detail.bank_and_enterprise_password"></el-input>
                    </div>
                </div>
            </div>
            <!-- 要占全宽部分start-->
            <div class="param_block_long  flex felxR">
                <div class="param_block_title">
                    <span v-if="type > 0">*</span>银企直联前置地址 :
                </div>
                <div class="param_block_input">
                    <div v-if="type === 0"> {{detail.bank_and_enterprise_address}} </div>
                    <div v-else>
                        <el-input type="text" clearable placeholder="银企直联前置地址"  v-model="detail.bank_and_enterprise_address"></el-input>
                    </div>
                </div>
            </div>
            <!-- 要占全宽部分end-->
        </div>

        <!-- 新增、编辑的时候还有下面的按钮，用于提交数据 -->
        <el-row style="margin-left:30px" v-show="type > 0">
            <el-button type="primary" @click="submitParam" >保存</el-button>
        </el-row>
        </div>
    </div>
</template>

<script>
export default {
    name: "FacilitatorParamDetail",
    props:{
        type:{              //编辑类型：0：查看、1：新增、2：编辑
            type: Number,
            default: 1
        },
        facilitator_id_add: 0,      //新增服务商时传过来的服务商ID
    },
    data(){
        return  {
            facilitator_id:0,           //服务商ID
            detail:{                            //基本信息资料
                facilitator_bank_code : '',   // '服务商入账账户',
                facilitator_account_name : '',  // '服务商入账户名',
                facilitator_bank_name : '',     // '服务商入账开户行',
                facilitator_pay_code :  '',     // '代付商户编号',
                facilitator_sign_key :  '',     // '代付商户签名密钥',
                facilitator_sm2_pub :   '',     // '代付商户SM2公钥',
                facilitator_sm2_key :   '',     // '代付商户SM2密钥',
                bank_and_enterprise_name :  '',     // '银企直联用户名',
                bank_and_enterprise_password :  '',     // '银企直联密码',
                bank_and_enterprise_address :   ''     // '银企直联前置地址',  
            }
        }
        
    },
    watch:{
        facilitator_id_add(newVal, oldVal){
            this.facilitator_id = newVal;
        }
    },
    mounted() {
        if(parseInt(this.$route.query.facilitator_id) > 0){
            this.facilitator_id = parseInt(this.$route.query.facilitator_id);
            this.facilitatorParamDetail();
        }
    },
    methods:{
        facilitatorParamDetail(){           //获取服务商参数详情
            this.$raxios.post(this.$mapapi.facilitatorParamDetail, {data:{facilitator_id: this.facilitator_id}}).then(res => {
                if(res.code != 200)     return  Promise.reject(res.msg);
                if(typeof res.data == 'object')     this.detail = res.data;
            }).catch(res => {
                this.$message.error(res);
            });
        },

        submitParam(){
            this.detail.facilitator_id = this.facilitator_id;
            let post_data = this.detail;
            if(!this.facilitator_id)    post_data.facilitator_id = this.detail.facilitator_id;
            this.$raxios.post(this.$mapapi.saveFacilitatorParam, {data:post_data}).then(res => {
                if(res.code != 200){
                    return  Promise.reject(res.msg);
                }
                if(this.type == 1){         //新增的话，还需要向父级发送消息，再进行下一步
                    this.$emit('submitParam');
                }else{              //编辑的话，这里直接弹出成功信息即可
                    this.$message.success(res.msg);
                    let that = this;
                    setTimeout(function() {
                        that.$blackRoute({ path: '/facilitator_list',query:{},that:this});                 // 返回指定路由-删除标题栏
                    }, 500);
                }
            }).catch(res => {
                this.$message.error(res);
                
            });
        }
    }
    

    }
</script>

<style  lang="less" :scope="true" src="@/style/facilitator/facilitator_list/facilitator_param_detail.less">

</style>
